package com.coldchain.cys.api;


import com.coldchain.authclient.annotation.CheckUserToken;
import com.coldchain.common.msg.BaseResponse;
import com.coldchain.common.msg.ObjectRestResponse;
import com.coldchain.cys.entity.AccidentType;
import com.coldchain.cys.entity.CarAccident;
import com.coldchain.cys.mapping.ApiUtils;
import com.coldchain.cys.page.CarAccidentQueryVo;
import com.coldchain.cys.service.IAccidentTypeService;
import com.coldchain.cys.service.ICarAccidentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author tianpeng
 * @since 2018-09-20
 */
@RestController
@CheckUserToken
@Api(description="车辆事故管理模块")
public class CarAccidentController {

	@Autowired
	private ICarAccidentService carAccidentService ;

	@Autowired
	private IAccidentTypeService accidentTypeService ;

	@ApiOperation(value="事故上报")
	@ApiImplicitParams(value={
			@ApiImplicitParam(name="type",value="事故的类型",dataType="String",paramType="query"),
			@ApiImplicitParam(name="content",value="事故描述说明",dataType="String",paramType="query"),
			@ApiImplicitParam(name="imagepath",value="事故拍照",dataType="String",paramType="query"),
			@ApiImplicitParam(name="lat",value="纬度",dataType="String",paramType="query"),
			@ApiImplicitParam(name="lon",value="经度",dataType="String",paramType="query"),
	})
	@RequestMapping(value=ApiUtils.DO_ADD_CAR_ACCIDENT,method= {RequestMethod.POST})
	public BaseResponse doAddCarAccident(@ApiIgnore CarAccident carAccident) {
		return carAccidentService.doAddCarAccident(carAccident) ;
	}

	@ApiOperation(value="车辆事故类型")
	@RequestMapping(value=ApiUtils.SHOW_CAR_ACCIDENT_TYPE_LIST,method= {RequestMethod.GET})
	public ObjectRestResponse<List<AccidentType>> showCarAccidentTypeList(){
		List<AccidentType> list = accidentTypeService.list(null);
	
		return new ObjectRestResponse<List<AccidentType>>(list) ;
	}

	@ApiOperation(value="车辆事故列表")
	@ApiImplicitParams(value={
			@ApiImplicitParam(name="driverid",value="司机的id",dataType="Long",paramType="query"),
			@ApiImplicitParam(name="current",value="页码",dataType="Integer",paramType="query"),
	})
	@RequestMapping(value=ApiUtils.SHOW_CAR_ACCIDENT_LIST,method= {RequestMethod.GET})
	public ObjectRestResponse<CarAccidentQueryVo> showCarAccidentList(CarAccidentQueryVo vo){
		carAccidentService.getCarAccidentList(vo) ;
		return new ObjectRestResponse<CarAccidentQueryVo>(vo) ;
	}

}

